<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport"
    content="width=device-width, initial-scale=1.0">
  <title>拟态demo4质感滑动按钮</title>
  <link rel="stylesheet"
    href="./styles/index.css">
</head>

<body class="body">
  <label>
    <input type="checkbox">
    <div id="icon">
      <div id="iconBox">
        <div id="cir"></div>
        <div id="hh"></div>
      </div>
    </div>
  </label>
</body>
<script>
  const themeBtn = document.querySelector('input')
  const body = document.querySelector('body')
  let flag = true
  themeBtn.addEventListener('change', () => {
    body.style.backgroundColor = flag ? '#ececec' : '#444'
    flag = !flag
  })
</script>

</html>